package com.nbsaas.boot.front.cms;

import com.nbsaas.boot.cms.api.apis.DownFileApi;
import com.nbsaas.boot.cms.api.domain.request.DownFileRequest;
import com.nbsaas.boot.cms.api.domain.request.DownFileSearch;
import com.nbsaas.boot.cms.api.domain.response.DownFileResponse;
import com.nbsaas.boot.cms.api.domain.simple.DownFileSimple;
import com.nbsaas.boot.rest.annotations.ViewOperator;
import com.nbsaas.boot.rest.response.ListResponse;
import com.nbsaas.boot.rest.response.PageResponse;
import com.nbsaas.boot.rest.response.ResponseObject;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

/**
 * 控制器
 */
@RequestMapping("/front/downFile")
public class DownFileAction {


    @Resource
    private DownFileApi downFileApi;

    /**
     * 搜索数据
     *
     * @param request
     * @return
     */
    @PostMapping("/search")
    public PageResponse<DownFileSimple> search(@RequestBody DownFileSearch request) {
        return downFileApi.search(request);
    }

    /**
     * 列表数据
     *
     * @param request
     * @return
     */
    @PostMapping("/list")
    public ListResponse<DownFileSimple> list(@RequestBody DownFileSearch request) {
        return downFileApi.list(request);
    }


    /**
     * 查看数据
     *
     * @param request
     * @return
     */
    @PostMapping("/view")
    public ResponseObject<DownFileResponse> view(@RequestBody @Validated(ViewOperator.class) DownFileRequest request) {
        return downFileApi.view(request);
    }
}